<template>
  <div class="app-container">
    <div class="main-container">
      <!-- 左侧导航栏 -->
      <aside class="sidebar">
        <div class="sidebar-header">
          <div class="logo-container">
            <div class="logo-circle">
              <img src="../static/icon/力量训练.png" alt="Logo" class="logo"/>
            </div>
            <h1 class="system-title">进步中</h1>
          </div>
        </div>
        <ul class="nav-menu">
          <li class="nav-item">
            <router-link to="/home" active-class="active">
              <i class="el-icon-s-home"></i>
              <span>首页</span>
            </router-link>
          </li>
          <li class="nav-item">
            <router-link to="/plan-list" active-class="active">
              <i class="el-icon-s-claim"></i>
              <span>打卡计划</span>
            </router-link>
          </li>
          <li class="nav-item">
            <router-link to="/check-in-record" active-class="active">
              <i class="el-icon-s-order"></i>
              <span>打卡记录</span>
            </router-link>
          </li>
          <li class="nav-item">
            <router-link to="/profile" active-class="active">
              <i class="el-icon-user"></i>
              <span>个人中心</span>
            </router-link>
          </li>
        </ul>
      </aside>

      <!-- 主内容区域 -->
      <main class="content">
        <!-- 顶部导航栏 -->
        <header class="top-navbar">
          <div class="header-right">
            <router-link to="/plan-create">
              <el-button type="primary" round>
                <el-icon>
                  <Plus/>
                </el-icon>
                新建计划
              </el-button>
            </router-link>
            <div class="avatar-container" @click="goToProfile">
              <!-- 头像图片 -->
              <img src="../static/img/迪迦点赞.jpg" alt="Avatar" class="avatar"/>
            </div>
          </div>
        </header>
        <slot></slot>
      </main>
    </div>
  </div>
</template>

<script>
import {Plus} from '@element-plus/icons-vue'

export default {
  name: 'AppLayout',
  components: {
    Plus
  },
  methods: {
    goToProfile() {
      this.$router.push('/profile');
    }
  }
}
</script>

<style scoped>
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
}

.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 左侧导航栏样式 */
.sidebar {
  width: 200px;
  background-color: #f5f7fa;
  border-right: 1px solid #e6e6e6;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.sidebar-header {
  padding: 20px;
  background-color: #4A90E2;
  color: white;
}

/* 顶部导航栏样式 */
.top-navbar {
  height: 60px;
  background-color: white;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.logo-container {
  display: flex;
  align-items: center;
}

.logo-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #ffffff; /* 橙色背景 */
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  border: 2px solid #ff9800;
  overflow: hidden;
}

.logo {
  height: 24px; /* 稍微缩小一点，让它在圆圈内有一些边距 */
  width: auto;
}

.system-title {
  font-size: 18px;
  margin: 0;
  color: white;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.avatar-container {
  cursor: pointer;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.3s;
}

.avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* 主容器样式 */
.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 侧边栏样式 */
.sidebar {
  width: 200px;
  background-color: #f5f7fa;
  border-right: 1px solid #e6e6e6;
  overflow-y: auto;
}

.nav-menu {
  padding: 0;
  margin: 0;
  list-style: none;
}

.nav-item {
  margin: 0;
  padding: 0;
}

.nav-item a {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  color: #606266;
  text-decoration: none;
  transition: all 0.3s;
}

.nav-item a:hover, .nav-item a.active {
  background-color: #ecf5ff;
  color: #4f46e5;
}

.nav-item i {
  margin-right: 10px;
  font-size: 18px;
}

/* 内容区域样式 */
.content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background-color: #f0f2f5;
}
</style>